﻿$(function() {
    $('#dlgcustomer-join').dialog('close');
});

$(window).load(function() {
       
    $("#ckbinditem").click(function() {
        if ($("#ckbinditem").attr("checked")) {
             $('#dlgcustomer_itemcode').combobox('enable');
             $('#dlgcustomer_maturity').datebox('enable');
             $('#dlgcustomer_Lastsurplus').numberbox('enable');
             $('#dlgcustomer_LastLateFee').numberbox('enable');
             
        }
        else {
             $('#dlgcustomer_itemcode').combobox('disable');
             $('#dlgcustomer_maturity').datebox('disable');
             $('#dlgcustomer_Lastsurplus').numberbox('disable');
             $('#dlgcustomer_LastLateFee').numberbox('disable');
             
        }
    });
});

function customerjoin_show(){
    $('#dlgcustomer-join').dialog('open');
    $('#dlgcustomer_itemcode').combobox({ url: '../Controller.aspx?controller=RoomBrowseController&method=GetCbServiceItemData&ItemType=0'});
    
    $('#dlgcustomer_name').val('');
    $('#dlgcustomer_ownername').val('');
    $('#dlgcustomer_tel').val('');
    $('#dlgcustomer_maturity').datebox('setValue','');
    $('#dlgcustomer_Lastsurplus').numberbox('setValue','');
    $('#dlgcustomer_LastLateFee').numberbox('setValue','');
    $("#ckbinditem").attr("checked","checked");
    
    $('#dlgcustomer_itemcode').combobox('enable');
    $('#dlgcustomer_maturity').datebox('enable');
    $('#dlgcustomer_Lastsurplus').numberbox('enable');
    $('#dlgcustomer_LastLateFee').numberbox('enable');
             
}

function btn_customersearchowner(){
    $('#dlg-searchowner').dialog('open');
    $('#searchownerType').val(1);
}

function btn_customersearchowner_queding(seleced){
     $('#dlgcustomer_ownername').val(seleced.Name);
     $('#dlgcustomer_tel').val(seleced.OftenMobile);
     $('#dlgcustomer_ownerId').val(seleced.OwnerId);
}

function dlg_joincustomer_queding(){
    //
    if (formvalidate('dlgcustomer-join') == false) return false;
    
     if ($("#ckbinditem").attr("checked"))
     {
        if($('#dlgcustomer_itemcode').combobox('getValue')=='')
        {
            $.messager.alert('提示', "先选择收费项目!", 'info');
            return false;
        }
        if($('#dlgcustomer_maturity').datebox('getValue')=='')
        {
            $.messager.alert('提示', "先填写到期日!", 'info');
            return false;
        }
        if($('#dlgcustomer_Lastsurplus').val()=='')
        {
            $.messager.alert('提示', "先填写上次余额!", 'info');
            return false;
        }
        if($('#dlgcustomer_LastLateFee').val()=='')
        {
            $.messager.alert('提示', "先填写上次滞纳金!", 'info');
            return false;
        }
     }
    var param={customer_name:$('#dlgcustomer_name').val(),ownerId:$('#dlgcustomer_ownerId').val(),OwnerName:$('#dlgcustomer_ownername').val(),tel:$('#dlgcustomer_tel').val(),itemcode:$('#dlgcustomer_itemcode').combobox('getValue'),maturity:$('#dlgcustomer_maturity').datebox('getValue'),Lastsurplus:$('#dlgcustomer_Lastsurplus').val(),LastLateFee:$('#dlgcustomer_LastLateFee').val()};
    requestAjax('../Controller.aspx?controller=RoomBrowseController&method=CustomerJoin', param, function(data) {
        $('#floor').floor('reload');
        $('#dlgcustomer-join').dialog('close');
    });
}